<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="/WEB-INF/views/_linkPages/basePath.jsp" %>
<!DOCTYPE html>
<%--修改密码--%>
<!-- saved from url=(0053)http://www.maomijiaoyi.com/index.php?/xiugaimima.html -->
<html lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

    <title>猫咪交易网,我的信息-修改密码</title>
    <meta name="keywords" content="宠物猫,买猫,卖猫,宠物猫交易,宠物猫价格">
    <meta name="description"
          content="猫咪交易网(www.maomijiaoyi.com)行业购宠第一品牌，千万家卖猫商家入驻覆盖全国各地，买放心宠物猫、了解最全面的宠物猫价格就上猫咪交易网、12年品牌值得信赖！">

    <link rel="stylesheet" href="${basePath}jsp/hs/css/usercenter.css">
    <link rel="stylesheet" href="${basePath}jsp/hs/css/comment.css">
    <script src="${basePath}jsp/hs/js/jquery-1.11.3.min.js" type="text/javascript" charset="utf-8"></script>
    <script src="${basePath}jsp/hs/js/comment.js" type="text/javascript" charset="utf-8"></script>
</head>
<body>

<!-- 引入公共头部 -->
<!-- 网页头部 -->
<%@ include file="cat/head.jsp"%>

<div style="height: 80px;"></div>

<!-- 面包屑导航栏 Crumbs_nav-->
<div id="Crumbs_nav">
    <a target="_blank" href="http://localhost:8080/jsp/hs/index.jsp">首页 &gt;</a>

    <a href="http://localhost:8080/jsp/hs/modify.jsp"><span>修改密码</span></a>
</div>


<!-- 个人中心 user_box-->
<div id="user_box" style="border: #eee solid 3px; box-sizing: border-box;">

    <!-- 左侧侧边栏 -->
    <div id="left_side">

        <a href="http://localhost:8080/jsp/hs/personal.jsp">
            <img src="${basePath}jsp/hs/img/userinfo.png" alt="">
            <p>个人信息</p>
        </a>

        <a href="http://localhost:8080/jsp/hs/modify.jsp">
            <img src="${basePath}jsp/hs/img/xiugai_zl.png" alt="">
            <p>修改资料</p>
        </a>

        <a href="http://localhost:8080/jsp/hs/password.jsp" style="background: rgba(56,50,50,0.2);">
            <img src="${basePath}jsp/hs/img/xiugai_pwd.png" alt="">
            <p>修改密码</p>
        </a>

        <a href="http://localhost:8080/jsp/hs/myPost.jsp">
            <img src="${basePath}jsp/hs/img/my_post.png" alt="">
            <p>我的帖子</p>
        </a>


    </div>


    <!-- 右侧信息展示 -->
    <div id="right_infobox">

        <p class="base_info">修改密码</p>

        <!-- 修改密码表单 -->
        <div id="form_box">

            <form action="${basePath}head" method="post"
                  id="regForm" onsubmit="return cheackinput(this)">

                <div class="input_box">
                    <input type="hidden" name="method" value="passowrd">
                    <input type="hidden" name="id" value="${user.id}">
                    　　原密码：
                    <input type="password" onblur="cheackpassword()" name="password" id="password">
                    <span id="y_pwd"></span>
                </div>

                <div class="input_box">
                    　　新密码：
                    <input type="password" placeholder="字母开头6--16位" onblur="cheacknewpwd()" name="newpwd" id="newpwd">
                    <span id="x_pwd"></span>
                </div>

                <div class="input_box">
                    确认新密码：
                    <input type="password" name="confirm_new_password" onblur="cheackconfirmpwd()" id="confirmnewpwd">
                    <span id="qrx_pwd"></span>
                </div>

                <div id="save_submit" onclick="cheackinput()">保　存</div>


            </form>

        </div>

    </div>

</div>

<div style="height: 80px;"></div>

<!-- 引入公共尾部 -->
<!-- 网页底部 -->
<div id="footer">

    <div class="logo">
        <div class="logo_kuang">
            <div>
                <a href="http://localhost:8080/jsp/hs/index.jsp">
                    <img alt="猫咪交易网" title="猫咪交易网" src="${basePath}jsp/hs/img/logo.png">
                </a>
            </div>
        </div>
    </div>


    <div class="banquan">
        <div class="center_1220">
            版权所有：猫咪交易网 www.maomijiaoyi.com 友情链接互换:qq 3416807849
        </div>
    </div>

    <div class="banquan">
        <div class="center_1220">
            【免责声明：本站所有猫猫交易信息内容系用户自行发布，其真实性、合法性由发布人负责，本站不提供任何保证，亦不承担任何法律责任！】
        </div>
    </div>

    <div class="banquan">
        <div class="center_1220">
            <a style="color: #FFF;" href="http://www.beian.gov.cn/portal/registerSystemInfo" target="_blank">
                <img src="${basePath}jsp/hs/img/foot_link3.png">
                沪ICP备18022709号-1 </a>
        </div>
    </div>

</div>

<script type="text/javascript">
    // 验证密码
    function cheackpassword() {
        var password = document.getElementById("password").value;
        var cheackpassword = new RegExp(/^[a-zA-Z]\w{5,15}$/);
        if (password.length <= 0) {

            document.getElementById('y_pwd').innerHTML = '密码不能为空';
            return false;
        }

        if (password.length < 6) {

            document.getElementById("password").value = '';
            document.getElementById('y_pwd').innerHTML = '密码长度不足';
            return false;
        }

        if (password.length > 16) {

            document.getElementById("password").value = '';
            document.getElementById('y_pwd').innerHTML = '密码长度超出';
            return false;
        }



        if (cheackpassword.test(password)) {
            $.get("${basePath}head?method=querypassword&password="+password+"&id="+${user.id}, function (data) {
                console.log("data:"+data)
                if (data == -1) {
                    document.getElementById("password").value = '';
                    document.getElementById('y_pwd').innerHTML = '密码不正确';
                    return false;
                } else {
                    document.getElementById('y_pwd').innerHTML = '';
                }
            });
            return true;
        } else {

            document.getElementById("password").value = '';
            document.getElementById('y_pwd').innerHTML = '密码格式不正确';
            return false;
        }
    };

    //验证新密码
    function cheacknewpwd() {
        var newpwd = document.getElementById("newpwd").value;
        var cheackpassword = new RegExp(/^[a-zA-Z]\w{5,15}$/);
        if (newpwd.length <= 0) {

            document.getElementById('x_pwd').innerHTML = '新密码不能为空';
            return false;
        }

        if (newpwd.length < 6) {

            document.getElementById("newpwd").value = '';
            document.getElementById('x_pwd').innerHTML = '新密码长度不足';
            return false;
        }

        if (newpwd.length > 16) {

            document.getElementById("newpwd").value = '';
            document.getElementById('x_pwd').innerHTML = '新密码长度超出';
            return false;
        }



        if (cheackpassword.test(newpwd)) {
            document.getElementById('x_pwd').innerHTML = '';
            return true;
        } else {

            document.getElementById("newpwd").value = '';
            document.getElementById('x_pwd').innerHTML = '新密码格式不正确';
            return false;
        }


    };

    //验证确认新密码
    function cheackconfirmpwd() {
        var newpwd = document.getElementById("newpwd").value;
        var newpwd2 = document.getElementById("confirmnewpwd").value;
        var cheackpassword = new RegExp(/^[a-zA-Z]\w{5,15}$/);
        if (newpwd.length <= 0) {

            document.getElementById('qrx_pwd').innerHTML = '确认新密码不能为空';
            return false;
        }

        if (newpwd.length < 6) {

            document.getElementById("confirmnewpwd").value = '';
            document.getElementById('qrx_pwd').innerHTML = '确认新密码长度不足';
            return false;
        }

        if (newpwd.length > 16) {

            document.getElementById("confirmnewpwd").value = '';
            document.getElementById('qrx_pwd').innerHTML = '确认新密码长度超出';
            return false;
        }

        if (newpwd.test(newpwd2)){

        }else {
            document.getElementById('qrx_pwd').innerHTML = '两次密码不一致';
            return false;
        }
        if (cheackpassword.test(newpwd)) {
            document.getElementById('qrx_pwd').innerHTML = '';
            return true;
        } else {

            document.getElementById("confirmnewpwd").value = '';
            document.getElementById('qrx_pwd').innerHTML = '确认新密码格式不正确';
            return false;
        }
    }

    //表单提交验证
    function cheackinput() {
        var password = document.getElementById("password").value;
        if (password.length <= 0) {
            document.getElementById('y_pwd').innerHTML = '密码为空';
            return false;
        }
        var newpwd = document.getElementById("newpwd").value;
        if (newpwd.length <= 0) {
            document.getElementById('x_pwd').innerHTML = '新密码为空';
            return false;
        }
        var confirmnewpwd = document.getElementById("confirmnewpwd").value;
        if (confirmnewpwd.length <= 0) {

            document.getElementById('qrx_pwd').innerHTML = '确认新密码为空';
            return false;
        }
        if (newpwd != confirmnewpwd) {

            document.getElementById('qrx_pwd').innerHTML = '确认新密码错误';
            return false;
        }
        if (confirmnewpwd != newpwd){
            document.getElementById('qrx_pwd').innerHTML = '两次密码不一致';
        }
        var regForm = document.getElementById('regForm');
        regForm.submit();
    }


    function Toast(msg,duration){
        duration=isNaN(duration)?3000:duration;
        var m = document.createElement('div');
        m.innerHTML = msg;
        m.style.cssText="width:50%; min-width:150px; background:#000; opacity:0.5; height:40px; color:#fff; line-height:40px; text-align:center; border-radius:5px; position:fixed; top:40%; left:20%; z-index:999999; font-weight:bold;";
        document.body.appendChild(m);
        setTimeout(function() {
            var d = 0.5;
            m.style.webkitTransition = '-webkit-transform ' + d + 's ease-in, opacity ' + d + 's ease-in';
            m.style.opacity = '0';
            setTimeout(function() { document.body.removeChild(m) }, d * 1000);
        }, duration);
    }
    $(function() {

            console.log("${booleans}");
            console.log("${msg}");
            if ("${booleans}" == "true"){
                console.log(1)
                Toast('${msg}',2000);
            }
            //Toast('${msg}',2000);
        }

        <c:remove var="msg" scope="session"/>
        <c:remove var="booleans" scope="session"/>

    )

</script>


</body>
</html>